﻿using EventBusDemo.EventBus.Abstractions.Local;
using MediatR;

namespace EventBusDemo.EventBus.Local;

public class LocalEventBus : ILocalEventBus
{
    private readonly IPublisher _publisher;

    public LocalEventBus(IPublisher publisher)
    {
        _publisher = publisher;
    }

    public async Task Publish(IDomainEvent domainEvent, CancellationToken cancellationToken = default)
    {
        await _publisher.Publish(domainEvent, cancellationToken);
    }

    public async Task Publish<T>(T domainEvent, CancellationToken cancellationToken = default) where T : IDomainEvent
    {
        await _publisher.Publish(domainEvent, cancellationToken);
    }
}